﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace wrsm.common.utility {

    /// <summary>
    /// A collection of DateTime utility functionality, and extension methods
    /// </summary>
    [CLSCompliant(true)]
    public static class DateTimeUtility {

        /// <summary>
        /// Calculate epoch Time
        /// </summary>
        /// <param name="dateTime">Time to calculate</param>
        /// <returns>epoch time</returns>
        public static long GetUnixEpoch(this DateTime dateTime) {
            var unixTime = dateTime.ToUniversalTime() -
                new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            return Convert.ToInt64(unixTime.TotalSeconds);
        }

    }
}
